package com.firstgroup.dms.controller;

import com.firstgroup.dms.pojo.SupplierInformation;
import com.firstgroup.dms.service.impl.SupplierInformationServiceImpl;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
import io.swagger.annotations.Api;

import javax.annotation.Resource;

/**
 * (SupplierInformation)表控制层
 *
 * @author lumos
 * @since 2025-01-19 10:48:41
 */
@RestController
@RequestMapping("supplierInformation")
@Api(value = "(SupplierInformation)",tags = "(SupplierInformation)接口API")
@CrossOrigin
public class SupplierInformationController {
    /**
     * 服务对象
     */
    @Resource
    private SupplierInformationServiceImpl supplierInformationServiceImpl;

    /**
     * 一次性全部查询
     *
     * @return 查询结果
     */
    @GetMapping("/selectAll")
    public Map<String, Object> selectAll() {
        return supplierInformationServiceImpl.selectAll();
    }

    /**
     * 分页查询
     *
     * @param supplierInformation 筛选条件
     * @param page        要查询第几页
     * @param limit       每页显示多少条
     * @return 查询结果
     */
    @GetMapping("/selectByLimit")
    public Map<String, Object> selectByLimit(SupplierInformation supplierInformation, 
                                           @RequestParam(defaultValue = "1") int page,
                                           @RequestParam(defaultValue = "10") int limit) {
        return supplierInformationServiceImpl.selectByLimit(supplierInformation, page, limit);
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("/selectById")
    public Map<String, Object> selectById(@RequestParam Integer id) {
        return supplierInformationServiceImpl.selectById(id);
    }

    /**
     * 新增数据
     *
     * @param supplierInformation 实体
     * @return 新增结果
     */
    @PostMapping("/insert")
    public Map<String, Object> insert(@RequestBody SupplierInformation supplierInformation) {
        return supplierInformationServiceImpl.insert(supplierInformation);
    }

    /**
     * 编辑数据
     *
     * @param supplierInformation 实体
     * @return 编辑结果
     */
    @PutMapping("/updateById")
    public Map<String, Object> updateById(@RequestBody SupplierInformation supplierInformation) {
        return supplierInformationServiceImpl.updateById(supplierInformation);
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping("/deleteById")
    public Map<String, Object> deleteById(@RequestParam Integer id) {
        return supplierInformationServiceImpl.deleteById(id);
    }

}

